/* eslint valid-jsdoc: "off" */

'use strict';

const request = require('koa/lib/request');

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
const path = require('path')
const Op = require('sequelize').Op;
module.exports = appInfo => {
  /**
   * built-in config
   * @type {Egg.EggAppConfig}
   **/
  const config = exports = {};

  // use for cookie sign key, should change to your own and keep security
  config.keys = appInfo.name + '_1607303752617_9469';

  // add your middleware config here
  config.middleware = [];

  // add your user config here
  const userConfig = {
    // myAppName: 'egg',
  };
  config.security = {
    csrf : {
      enable : false,
    }
  }
  config.view = {
    defaultViewEngine:'nunjucks'
  }
  config.cors = {
    origin:'*',
    credentials:true,
    allowMethods:'POST,PUT,GET,DELETE,HEAD,PATCH,OPTIONS'
  }
  config.jwt = {
    secret:'wanghainanshishabi',
  }
  config.static = {
    prefix:'/',
    dir:path.join(appInfo.baseDir,'app/public'),
  }
  config.sequelize = {
    dialect:'mysql',
    database:'test',
    host:'localhost',
    port:3306,
    username:'root',
    password:'qazplm123',
    timezone:'+08:00',
    operatorsAliases:{
      $eq: Op.eq,
      $ne: Op.ne,
      $gte: Op.gte,
      $gt: Op.gt,
      $lte: Op.lte,
      $lt: Op.lt,
      $not: Op.not,
      $in: Op.in,
      $notIn: Op.notIn,
      $is: Op.is,
      $like: Op.like,
      $notLike: Op.notLike,
      $iLike: Op.iLike,
      $notILike: Op.notILike,
      $regexp: Op.regexp,
      $notRegexp: Op.notRegexp,
      $iRegexp: Op.iRegexp,
      $notIRegexp: Op.notIRegexp,
      $between: Op.between,
      $notBetween: Op.notBetween,
      $overlap: Op.overlap,
      $contains: Op.contains,
      $contained: Op.contained,
      $adjacent: Op.adjacent,
      $strictLeft: Op.strictLeft,
      $strictRight: Op.strictRight,
      $noExtendRight: Op.noExtendRight,
      $noExtendLeft: Op.noExtendLeft,
      $and: Op.and,
      $or: Op.or,
      $any: Op.any,
      $all: Op.all,
      $values: Op.values,
      $col: Op.col
    },
  }
  return {
    ...config,
    ...userConfig,
  };
};
